Skip to content

Conversation

@vicb
Copy link
Contributor

@vicb vicb commented Oct 14, 2024

Summary

Change event.respondWith(...) for Response.

event.respondWith(...) is the old Service Worker API that is no more recommended.

Note that the code snippet on this page is correctly using the Module Worker API.

reference: https://developers.cloudflare.com/workers/runtime-apis/fetch/

Documentation checklist

Copy link
Contributor

@irvinebroque irvinebroque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one

<DirectoryListing />

Workers do not need to prepare an entire response body before delivering it to `event.respondWith()`. You can use [`TransformStream`](/workers/runtime-apis/streams/transformstream/) to stream a response body after sending the front matter (that is, HTTP status line and headers). This allows you to minimize:
Workers do not need to prepare an entire response body before returning a `Response`. You can use [`TransformStream`](/workers/runtime-apis/streams/transformstream/) to stream a response body after sending the front matter (that is, HTTP status line and headers). This allows you to minimize:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@irvinebroque Rereading that paragraph I think "You can use TransformStream" should actually be "You can use a ReadableStream"

Note that TransformStream implements ReadableStream so the current phrasing is not wrong, just a specialization of the generic case.

I can amend this PR or create a new one.

WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go for it either way

@vicb vicb changed the title Update index.mdx to use the module syntax Update Stream documentation Oct 14, 2024
@vicb vicb requested a review from irvinebroque October 14, 2024 16:39
- Use the module syntax over
- TransformStream -> ReadableStream
- let -> const where applicable
@vicb
Copy link
Contributor Author

vicb commented Oct 17, 2024

@kodster28 could you please help me merge this?

@vicb vicb mentioned this pull request Oct 17, 2024
1 task
@github-actions github-actions bot added size/m and removed size/s labels Oct 17, 2024
@pedrosousa pedrosousa merged commit 5c413eb into cloudflare:production Oct 17, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:workers Related to Workers product size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants